package buisness_service;

import java.util.List;

public class Common_methods {

	public static float SommeTotalDepenses(List<Depense> depenses) {
		float montantTotal = 0;
		for (int i = 0; i < depenses.size(); i++)
			montantTotal += depenses.get(i).getMontant();
		return montantTotal;
	}

	public static float SommeTotalRevenus(List<Revenu> revenus) {
		float montantTotal = 0;
		for (int i = 0; i < revenus.size(); i++)
			montantTotal += revenus.get(i).getMontant();
		return montantTotal;
	}

	public static float Epargne(List<Depense> depenses, List<Revenu> revenus) {

		float sommeDepense = SommeTotalDepenses(depenses);
		float sommeRevenu = SommeTotalRevenus(revenus);
		float economie = 0;
		economie = sommeRevenu - sommeDepense;
		return economie;
	}

	public static float SommeTotalDepenseMois(Depense_mois dep_mois) {
		float s = 0;
		for (int i = 0; i < dep_mois.getDepenses_jour().size(); i++) {
			s += Common_methods.SommeTotalDepenses(dep_mois.getDepenses_jour()
					.get(i).getDepenses());
		}
		return s;
	}
	

	public static float SommeTotalrevenuMois(Revenu_mois rev_mois)
	{
		float s=0;
		for (int i = 0; i < rev_mois.getRevenus_jour().size(); i++) {
			s += Common_methods.SommeTotalRevenus(rev_mois.getRevenus_jour()
					.get(i).getRevenu());
		}
		return s;
	}
}
